<?php
/*
 * @Author: 李志刚
 * @CopyRight: 2020-2030 衡水山木枝技术服务有限公司
 * @Date: 2021-07-05 17:55:56
 * @Description: 验证租户是不是超级管理员
 * @LastEditors: 李志刚
 * @LastEditTime: 2021-09-16 09:57:31
 * @FilePath: /qingshanERP/app/Http/Middleware/TenantSuperJwt.php
 */
namespace App\Http\Middleware;

use Closure;

class TenantSuperJwt {
	/**
	 * Handle an incoming request.
	 *
	 * @param  \Illuminate\Http\Request  $request
	 * @param  \Closure  $next
	 * @return mixed
	 */
	public function handle($request, Closure $next) {
		try {
            if (!$request->tenant->super) {
                return response()->json(['code' => 400, 'msg' => '此账户无管理权限...']);
            }
            return $next($request);
		} catch (\Throwable $e) {
			return response()->json(['code' => 401, 'msg' => '验证权限失败...', 'data' => ''.$token]);
		}
	}
}
